<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('COM_JHTRAQ_RELEASE_ADD_EDIT'), 'generic.png');
JToolBarHelper::save();
JToolBarHelper::cancel();
$document =& JFactory::getDocument();
$document->addScript(str_replace("administrator/","",JURI::base()) . 'components/com_jhtraq/extras/jquery-1.3.2.min.js');
?>
<?php JHTML::_('behavior.calendar'); ?>
<?php JHTML::_('behavior.tooltip'); ?>
<script language="javascript" type="text/javascript">

jQuery(document).ready(function() {
	var pid = jQuery('#project_id').val();
	jQuery('#versionlist').load('index.php?option=com_jhtraq&view=releases&task=vlist&pid='+pid+'&vid=<?php echo $this->release->version_id;?>');
	
	jQuery('#project_id').change(function() {
		var pid = jQuery('#project_id').val();
		jQuery('#versionlist').load('index.php?option=com_jhtraq&view=releases&task=vlist&pid='+pid+'&vid=<?php echo $this->release->version_id;?>');
	});
});

</script>
<form action="index.php?option=com_jhtraq&view=releases" method="post" name="adminForm">
<input type="hidden" name="task" value="" />
<input type="hidden" name="id" value="<?php echo (int)$this->release->id;?>" />

<table class="adminlist" cellpadding="1">
<tr>
	<td width="150"><label for="name"><?php echo JText::_('COM_JHTRAQ_RELEASE_NAME');?></label></td>
	<td><input type="text" name="name" id="name" value="<?php echo $this->release->name;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="project_id"><?php echo JText::_('COM_JHTRAQ_PROJECT');?></label></td>
	<td><select name="project_id" id="project_id" />
	<?php
	foreach($this->projects as $pid=>$pname)
	{
		echo '<option value="'.$pid.'" ';
		if($pid == $this->release->project_id) echo 'SELECTED';
		echo '>' . $pname . '</option>';
	}
	?></select>
	</td>
</tr>
<tr>
	<td width="150"><label for="version_id"><?php echo JText::_('COM_JHTRAQ_RELEASE_VERSION');?></label></td>
	<td id="versionlist"></td>
</tr>
<tr>
	<td width="150"><label for="jhshop_prod_id"><?php echo JText::_('COM_JHTRAQ_JHSHOP_PRODUCT');?></label></td>
	<td><select name="jhshop_prod_id" id="jhshop_prod_id">
			<option value="0"><?php echo JText::_('COM_JHTRAQ_NONE');?>
			<?php 
			foreach($this->jhshopProds as $pid=>$pname)
			{
				echo '<option value="'.$pid.'" ';
				if($pid == $this->release->jhshop_prod_id) echo 'Selected';
				echo '>'.$pname.'</option>';
			}
			?>
		</select>
	</td>
</tr>
<?php 
$ambra_existing = explode(",", $this->release->ambrasubs_types);
?>
<tr>
	<td width="150"><label for="ambrasubs_types"><?php echo JText::_('COM_JHTRAQ_AMBRA_SUBSCRIPTIONS');?></label></td>
	<td><select name="ambrasubs_types[]" id="ambrasubs_types" multiple="multiple" size="5">
			<option value="0"><?php echo JText::_('COM_JHTRAQ_NONE');?>
			<?php
			foreach($this->ambraTypes as $pid=>$pname)
			{
				echo '<option value="'.$pid.'" ';
				if(in_array($pid, $ambra_existing)) echo 'Selected';
				echo '>'.$pname.'</option>';
			}
			?>
		</select>
	</td>
</tr>
<tr>
	<td width="150"><label for="download_link"><?php echo JText::_('COM_JHTRAQ_DOWNLOAD_LINK');?></label></td>
	<td><input type="text" name="download_link" id="download_link" value="<?php echo $this->release->download_link;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="download_size"><?php echo JText::_('COM_JHTRAQ_FILE_SIZE');?></label></td>
	<td><input type="text" name="download_size" id="download_size" value="<?php echo $this->release->download_size;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="released"><?php echo JText::_('RELEASE_DATE');?></label></td>
	<td><input class="inputbox" type="text" name="released"
	id="released" size="25" maxlength="25"
	value="<?php echo ($this->release->released > 0) ?DATE("Y-m-d", $this->release->released):'';?>" />
	<input type="reset" class="button" value="..."
	onclick="return showCalendar('released','%Y-%m-%d');" /></td>
</tr>
<tr>
	<td width="150"><label for="published"><?php echo JText::_('COM_JHTRAQ_PUBLISHED');?></label></td>
	<td><select name="published" id="published">
			<option value="1"><?php echo JText::_('COM_JHTRAQ_YES');?></option>
			<option value="0" <?php if(!$this->release->published) echo 'Selected';?>><?php echo JText::_('COM_JHTRAQ_NO');?></option>
		</select>
	</td>
</tr>
</table>
</form>
